# @author : sentry
# @since : 2023-09-10
# 闰年问题

"""
输入年月日，输出该日期是否是闰年
并且输出该日期是此年份的第几天
[31,28,31,30,31,30,31,31,30,31,30,31]
"""

import datetime

# 每个月的天数
date_list = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

date_str = input('请输入日期（例如 2023-09-10）：')
date = datetime.datetime.strptime(date_str, '%Y-%m-%d')
if date.year % 4 == 0 and date.year % 100 != 0 or date.year % 400 == 0:
    print(f'{date.year}年是闰年')
    date_list[1] = 29
else:
    print(f'{date.year}年是平年')

# 天数初始值
count_day = date.day
for i in range(date.month - 1):
    # 天数累加
    count_day += date_list[i]
print(f'{date.year}年{date.month}月{date.day}日是当年的第{count_day}天')
